package com.ado.bazinga.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ado.bazinga.core.dal.entity.Operation;
import com.ado.bazinga.core.manager.OperationManager;
import com.ado.bazinga.core.service.OperationService;

/**
 *@author adonais
 *@date 2020年4月6日
 *@description OperationServiceImpl.java
**/
@Service(value = "operationService")
public class OperationServiceImpl implements OperationService {

	
	@Autowired
	@Qualifier(value = "operationManager")
	private OperationManager operationManager ;
	
	@Override
	public Operation findById(String id) {
		return operationManager.getById(Integer.valueOf(id));
	}

	@Override
	@Transactional
	public boolean createOperation(Operation operation) {
		boolean flag = operationManager.save(operation) ;
		return flag;
	}

	@Override
	@Transactional
	public boolean deleteOperation(String operationId) {
		boolean flag = operationManager.removeById(Integer.valueOf(operationId));
		return flag;
	}

	@Override
	public Operation getOperationById(String operationId) {
		Operation operation = operationManager.getById(Integer.valueOf(operationId)) ;
		return operation;
	}

	@Override
	@Transactional
	public boolean updateOperation(Operation operation) {
		boolean flag = operationManager.updateById(operation) ;
		return flag;
	}

	@Override
	public List<Operation> getAllOperations() {
		List<Operation> ops = operationManager.list() ;
		return ops;
	}

}
